/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package elaborate.h2x.transform;

import java.util.UUID;

/**
 *
 * @author lendle
 */
public class TransformingNodeId implements java.io.Serializable, Comparable<TransformingNodeId>{

    protected String id;

    public TransformingNodeId(String id) {
        this.id = id;
    }
    /**
     * automatically generate random id
     */
    public TransformingNodeId() {
        this(UUID.randomUUID().toString());
    }

    /**
     * Get the value of id
     *
     * @return the value of id
     */
    public String getId() {
        return id;
    }

    /**
     * Set the value of id
     *
     * @param id new value of id
     */
    public void setId(String id) {
        this.id = id;
    }

    public int compareTo(TransformingNodeId t) {
        return this.id.compareTo(t.id);
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final TransformingNodeId other = (TransformingNodeId) obj;
        if ((this.id == null) ? (other.id != null) : !this.id.equals(other.id)) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 31 * hash + (this.id != null ? this.id.hashCode() : 0);
        return hash;
    }

    public static TransformingNodeId fromString(String id){
        return new TransformingNodeId(id);
    }

    @Override
    public String toString() {
        return id;
    }
}
